import { FC } from "react";
import { NavigationListObj } from "../../../../types/headComp";

import styles from "./index.module.scss";
import { commonYntoBoolean } from "../../../../utils/global";
import { COMMONYN } from "../../../../enums/global";
import { NavigatiionEnum } from "../../../../enums/headComp";
import classNames from "classnames";

const NavigationCompItem: FC<
  NavigationListObj & {
    naviCode: NavigatiionEnum;
    onCheck: (code: NavigatiionEnum) => void;
  }
> = ({ ...props }) => {
  const {
    name,
    link,
    open = COMMONYN.NO,
    isHave = COMMONYN.NO,
    onCheck,
    naviCode,
  } = props;

  const itemOnClik = () => {
    // 跳转
    !commonYntoBoolean(open) && onCheck(name);
  };
  return (
    <div
      className={classNames(
        styles.item,
        name === naviCode ? styles.item_active : ""
      )}
      {...props}
      onClick={itemOnClik}
    >
      {commonYntoBoolean(isHave) && (
        <img
          src="	https://y.qq.com/mediastyle/yqq/extra/mark_1.png?max_age=2592000"
          alt=""
        />
      )}
      <span>{name}</span>
    </div>
  );
};
export default NavigationCompItem;
